package cn.t17.appsys.service.impl;

import cn.t17.appsys.dao.AppCategoryMapper;
import cn.t17.appsys.entity.AppCategory;
import cn.t17.appsys.service.AppCategoryService;
import cn.t17.appsys.vo.AppCategoryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * AppCategoryServiceImpl class
 *
 * @author Administrator
 * @date 2021/9/16
 */
@Service
public class AppCategoryServiceImpl implements AppCategoryService {
    @Autowired
    private AppCategoryMapper appCategoryMapper;

    @Override
    public List<AppCategoryVO> listByParentId(Long parentId) {
        List<AppCategory> appCategories =
                appCategoryMapper.listByParentId(parentId);

        List<AppCategoryVO> appCategoryVOS = new ArrayList<>();
        for (AppCategory category : appCategories) {
            AppCategoryVO vo = new AppCategoryVO();
            vo.setId(category.getId());
            vo.setCategoryName(category.getCategoryName());

            appCategoryVOS.add(vo);
        }
        return appCategoryVOS;
    }

}
